package com.chanceit.ssss.right;

import java.util.ArrayList;

import org.gl.utils.lg;
import org.json.JSONArray;
import org.json.JSONObject;

public abstract class RightGroup {
	public ArrayList<String> rightList = new ArrayList<String>();
	private String TAG = this.getClass().getSimpleName();

	public boolean isHasRight(String right) {
		return rightList.contains(right);
	};

	public boolean isHasRight(JSONArray rightJson) {
		 ArrayList<String> norightList = new ArrayList<String>();
		JSONObject jo;
		int tototal = 0;
		for (int i = 0; i < rightJson.length(); i++) {
			jo = rightJson.optJSONObject(i);
			if (isHasRight(jo.optString("rightCode"))) {
				tototal++;
				norightList.add(jo.optString("rightCode"));
			}
		}
		if (tototal==rightList.size()) {
			return true;
		}
		for (int i = 0; i < rightList.size(); i++) {
			if (!norightList.contains(rightList.get(i))) {
				lg.e(TAG , "no right:"+rightList.get(i));
			}
		}
		return false;
	};
}
